<?php
	
	require_once("fta.201003310000/fta.php");
	fta_registerModules(
		array(
		"cms.201003310000/config/cmsConfig",//we will deprecate the old cms config soon..
		"site/fta/config",
		"FTAWebPage/ftaDefaultWidgets",
		"FTAWebPage/FTAWebPage",
		"FTAFormMailer/ftaFormMailer"
	));	
	
	global $FTAWebPageDocumentType;
	$FTAWebPageDocumentType = 'docWebSnip';
	
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="Keywords" content="<?php echo $metadataKeywords; ?>" />
<meta name="Description" content="<?php echo $metadataDescription; ?>" />

<title><?php echo $pageTitle; ?> | Mairangi Arts Centre</title>

<?php include ("includes/external-files.php"); ?>



<script src="/js/jquery.inlined-forms.js" type="text/javascript"></script>
    
    
    
    
<?php include ("includes/analytics.php"); ?>   
</head>

<body id="contact" class="">



<?php include ("includes/head.php"); ?>





<div id="container">


	<div id="content">
    	
        <h1><?php echo $pageHeading; ?></h1>

         

        <div id="content-blocks">
        	
            <div class="content-block block1 first-block">
 
                <h2>
                    You are most welcome to contact us with your enquiries
                </h2>
                 
                <div id="contact-map">
                    <div id="map"></div>
                </div>

                <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>

					<script>
				var map;
				var geocoder;
				function initialize() {
				
				
					geocoder = new google.maps.Geocoder();

				    geocoder.geocode( { 'address': "20 Hastings Rd, Mairangi Bay, New Zealand"}, function(results, status) {
					if (status == google.maps.GeocoderStatus.OK) {
					  
					 
					   var latlng = new google.maps.LatLng(-34.397, 150.644);

					   var mapOptions = {
							zoom: 16,
							center: latlng,
							mapTypeId: google.maps.MapTypeId.ROADMAP
					  };
					  
					  map = new google.maps.Map(document.getElementById('map'),
						  mapOptions);
						  
					  map.setCenter(results[0].geometry.location);
					  var marker = new google.maps.Marker({
						  map: map,
						  icon: "/images/map-pointer.png",
						  position: results[0].geometry.location
					  });
					  
					} else {
					  alert('Geocode was not successful for the following reason: ' + status);
					}
				  });

				
				 
				}

				google.maps.event.addDomListener(window, 'load', initialize);

					</script>

                <?/*<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAShxGy2KEJn6aljByL6XHhBTSotDTpuejvw_bM7JiK8EPmZLTtRRHT-HIr1PUaOHk4IcMHii3kzRDEA" type="text/javascript"></script> 
				<script type="text/javascript">
                
                    //<![CDATA[
                
                    function loadMap() {
                      if (GBrowserIsCompatible()) {
                        var map = new GMap2(document.getElementById("map"));
                        var gc = new GClientGeocoder();
                        
                        
                            gc.getLocations("20 Hastings Rd, Mairangi Bay, New Zealand", function (loc){
                        
                            if (null == loc)
                                return; 
                                
                            p = loc.Placemark[0];
                            latlng = new GLatLng(p.Point.coordinates[1],p.Point.coordinates[0]);
                                        
                            map.setCenter( latlng, 16 );
                            
                            map.enableContinuousZoom();
                            map.addControl(new GSmallMapControl());
                            
                            var icon = new GIcon();
                            icon.image = "/images/map-pointer.png";
                            icon.shadow = "";
                            icon.iconAnchor = new GPoint(80.0, 40.0);
                            
                            var marker = new GMarker(latlng,icon,true);
                            map.addOverlay(marker);
                            
                                            
                        });
                         
                      }
                    }
                    
                    loadMap();
                
                    //]]>
                
                </script> */?>



                
                <div id="contact-details">
                    <?php echo $pageContent; ?>
                    
                    
                </div>
                
                <?php


					$authInfo = setupPublicUser();
					
					//ie cluster fuck 
					$submit_x = extractBooleanWithKeyFromArray('contact-submit_x',$_POST,false);
					$submit_y = extractBooleanWithKeyFromArray('contact-submit_y',$_POST,false);
					$submit = ($submit_x || $submit_y);
					$submit = extractBooleanWithKeyFromArray('contact-submit',$_POST,$submit);
					
					
					$formDescriptor = fta_getFormMailerFormDescriptor(2171,$db);
				
					$formSent = false;
					if ( $submit ) {
						$invalidFields = array();
						$recipients = array();		
						$formSent = fta_formMailerSendForm($formDescriptor,$_POST,$recipients, $authInfo, $invalidFields, $db );
						
				
						$toAddress = extractEmailWithKeyFromArray('email',$_REQUEST ,null);
						if ($formSent && !is_null($toAddress) && $formDescriptor->sendThankYouEmail){
				
							fta_formMailerSendThankYouEmail(
								array(
								$toAddress	
								),$formDescriptor
							);
						}		
					}
					
					if (!$formSent){
						
				?>
                
                <form id="contact-form" method="POST" action="<?= $_SERVER['REQUEST_URI'] ?>">
                	<div>
				        <?php 
				        	$inputValue = '';
				        	$inputValues = '';
				        	ob_start();
				        	fta_getFormMailerInputIdAndValue('name',$_REQUEST, $formDescriptor);
				        	$inputValue = ob_get_clean();
				        	$inputValues = explode(" ", $inputValue);
				        ?>
                        <label for="name" class="inlined<?php if (trim($inputValues[2]) != 'value=""') { echo " has-text"; } ?>">Name:</label>
                        <input class="input-text" <?= fta_getFormMailerInputIdAndValue('name',$_REQUEST, $formDescriptor); ?>/>
                        <?= fta_getFormMailerValidationMessageForField('name', $invalidFields, $formDescriptor); ?>
					</div>

                	<div>
				        <?php 
				        	$inputValue = '';
				        	$inputValues = '';
				        	ob_start();
				        	fta_getFormMailerInputIdAndValue('email',$_REQUEST, $formDescriptor);
				        	$inputValue = ob_get_clean();
				        	$inputValues = explode(" ", $inputValue);
				        ?>
                        <label for="email" class="inlined<?php if (trim($inputValues[2]) != 'value=""') { echo " has-text"; } ?>">Email:</label>
                        <input class="input-text" <?= fta_getFormMailerInputIdAndValue('email',$_REQUEST, $formDescriptor); ?>/>
                        <?= fta_getFormMailerValidationMessageForField('email', $invalidFields, $formDescriptor); ?>
					</div>
					
					<div>
						<?php
							$inputValue = '';
				        	$inputValues = '';
							ob_start();
							fta_getFormMailerInputIdAndValue('contactType',$_REQUEST, $formDescriptor);
							//fta_getFormMailerTextAreaValue('contactType',$_REQUEST, $formDescriptor);
							$inputValue = ob_get_clean();
							$inputValues = explode(" ", $inputValue);//echo $inputValues[2];
						?>
						
						<select name="contactType" id="contactType" class="input-text">
							<option value="" <?php if($inputValues[2] == 'value="" '){ echo "selected";} ?>>Select a contact type:</option>
							<option value="Becoming a member" <?php if($inputValues[2] == 'value="Becoming'){ echo "selected";} ?>>Becoming a member</option>
							<option value="Art class or workshop information" <?php if($inputValues[2] == 'value="Art'){ echo "selected";} ?>>Art class or workshop information</option>
							<option value="Facilities information and opening hours" <?php if($inputValues[2] == 'value="Facilities'){ echo "selected";} ?>>Facilities information and opening hours</option>
							<option value="Exhibition information" <?php if($inputValues[2] == 'value="Exhibition'){ echo "selected";} ?>>Exhibition information</option>
							<option value="Hiring the centre" <?php if($inputValues[2] == 'value="Hiring'){ echo "selected";} ?>>Hiring the centre</option>
							<option value="Volunteer or committee work" <?php if($inputValues[2] == 'value="Volunteer'){ echo "selected";} ?>>Volunteer or committee work</option>
							<option value="General enquiry" <?php if($inputValues[2] == 'value="General'){ echo "selected";} ?>>General enquiry</option>							
						</select>
						<?= fta_getFormMailerValidationMessageForField('contactType', $invalidFields, $formDescriptor); ?>
					</div>
					
                	<div>
				        <?php 
				        	$inputValue = '';
				        	$inputValues = '';
				        	ob_start();
				        	fta_getFormMailerInputIdAndValue('message',$_REQUEST, $formDescriptor);
				        	$inputValue = ob_get_clean();
				        	$inputValues = explode(" ", $inputValue);
				        ?>
                        <label for="message" class="inlined<?php if (trim($inputValues[2]) != 'value=""') { echo " has-text"; } ?>">Your message:</label>
                        <textarea rows="10" class="input-text" name="message"><?= fta_getFormMailerTextAreaValue('message',$_REQUEST, $formDescription); ?></textarea>
                        <?= fta_getFormMailerValidationMessageForField('message', $invalidFields, $formDescriptor); ?>
                    </div>                    


					<input name="contact-submit" id="contact-submit" type="submit" value="1"/>
					<?php //<input src="/images/submit.gif" name="contactSubmit" type="image" class="contactSubmit" value='1'/> ?>
					
                </form>

				<?php 
					} else {
				?>	
				<div class="contactEnquiryThankyou">	
					Thanks!  Your enquiry has been sent, and we'll be in touch shortly.

                    <ul class="nav-list">
                    	<li><a href="/Contact-Us/" title="Make another enquiry?">Make another enquiry?</a></li>
					</ul>
				</div>
					
						
				<?php		
					}
				?>
                
            </div><!-- Content-block ends -->

		</div><!-- Content-blocks ends -->
        
        
        
    
    
    
    	<div id="supplementary-content">
            
            <h3>Our Team</h3>

           	<ul id="contact-people">
                <li>
                	<?php echo fta_getPageContent("/Contact-Us/Our-Team/First/"); ?>
                	<?php /* ?>
                    <strong>Ellie Drummond</strong>
                    <div class="contact-position">Manager – enquiries re gallery hire, group exhibitions</div>
                    <a href="mailto:admin.mac@xtra.co.nz">admin.mac@xtra.co.nz</a>
                    <?php */ ?>
                </li>
                <li>
                	<?php echo fta_getPageContent("/Contact-Us/Our-Team/Second/"); ?>
                	<?php /* ?>
                    <strong>Christine Currey</strong>
                    <div class="contact-position">Operations &amp; Administration – enquiries re studio hire, voluteering, tutoring, accounts</div>
                    <strong>Phone:</strong> 09 478 2237<br />
                    <a href="mailto:mairangiartscentre@xtra.co.nz">mairangiartscentre@xtra.co.nz</a>
                    <?php */ ?>
                </li> 
                <li class="last-item">
                	<?php echo fta_getPageContent("/Contact-Us/Our-Team/Third/"); ?>
                	<?php /*  ?>
                    <strong>Cath O’Brien</strong>
                    <div class="contact-position">Front of House Assistant – enrolments, birthday parties, exhibition entry forms, general enquiries</div>
                    <strong>Phone:</strong> 09 478 2237<br />
                    <a href="mailto:mairangiartscentre@xtra.co.nz">mairangiartscentre@xtra.co.nz</a>
                    <?php */ ?>
                </li>
            </ul>

            
        </div><!-- Supplementary-content ends -->



    </div><!-- Content ends -->








    
</div><!-- Container ends -->





<?php include ("includes/foot.php"); ?>





</body>

</html>
